package org.smr.ministore.service.impl;

import java.util.List;

import org.blade.dao.base.BaseMapper;
import org.blade.utils.IdGenUtils;
import org.blade.utils.Pager;
import org.blade.service.base.AbstractService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.dao.GoodsTypePropsMapper;
import org.smr.ministore.entities.GoodsTypeProps;
import org.smr.ministore.service.GoodsTypePropsService;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;

@Service("GoodsTypePropsService")
public class GoodsTypePropsServiceImpl extends AbstractService<Long,GoodsTypeProps> implements GoodsTypePropsService {


    private static Logger logger = LoggerFactory.getLogger(GoodsTypePropsServiceImpl.class);


	@Autowired
	private GoodsTypePropsMapper mapper;

	@Autowired
	public GoodsTypePropsServiceImpl(GoodsTypePropsMapper mapper) {
		super(mapper);
	}

	public int save(GoodsTypeProps entity) {
		super.saveAttatch(entity);

		return mapper.insert(entity);
	}

	public int updateById(GoodsTypeProps id) {
		super.modifyAttach(id);

		return mapper.updateById(id);
	}

	public GoodsTypeProps queryById(Long id) {
		return mapper.selectById(id);
	}

	public int deleteById(Long id) {
		return mapper.deleteById(id);
	}

	public Pager<GoodsTypeProps> paginate( GoodsTypeProps entity, Long pageSize, Long pageNum) {

		Pager<GoodsTypeProps> pager = new Pager( pageSize, pageNum );
		List list  = mapper.pagination(entity, pager);
		pager.setEntities(list);
		return pager;
    }
	
	public int batchSave(List<GoodsTypeProps> entities) {
        this.batchSaveAttatch(entities);
		return mapper.batchInsert(entities);
	}


    public int batchModify(List<GoodsTypeProps> entities) {
        this.batchModifyAttatch(entities);
        return mapper.batchUpdate(entities);
        }


    public int deleteByIdLogical(Long id) {
        return mapper.deleteByIdLogical(id);
    }


	public Long getId() {
		return IdGenUtils.getNextLongId();
	}
}
